class Watcher {
	constructor(vm, key, cb) {
		this.vm = vm
		this.key = key
		this.cb = cb
		//记录当前的watcher对象到Dep中
		Dep.target = this
		this.oldValue = vm[key]
		//防止重复添加
		Dep.target = null
	}

	update() {
		let newValue = this.vm[this.key]
		if (this.oldValue === this.newValue) {
			return
		}
		this.cb(newValue)
	}
}